package org.pgis.gui;

import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JLabel;

import org.pgis.core.AbstractScenePanel;
import org.pgis.entity.ComponentViewEnum;
import org.pgis.entity.RepresentationEnum;

import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class RepresentationPanel extends JPanel{

	private static final long serialVersionUID = 1L;
	private AbstractScenePanel asp;
	public RepresentationPanel(AbstractScenePanel asp) {
		this.asp = asp;
		initialize();
	}

	private void initialize() {

		this.setLayout(null);

		JLabel labelColor = new JLabel("View Modes");
		labelColor.setFont(new Font("Century", Font.BOLD, 16));
		labelColor.setBounds(79, 11, 126, 30);
		this.add(labelColor);

		JButton buttonSolidView = new JButton("Solid");
		buttonSolidView.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				asp.getSim().setRepresentation(RepresentationEnum.SOLID);
				asp.refresh();
			}
		});
		buttonSolidView.setBounds(10, 52, 106, 32);
		this.add(buttonSolidView);

		JButton buttonWireframeView = new JButton("Wireframe");
		buttonWireframeView.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				asp.getSim().setRepresentation(RepresentationEnum.WIREFRAME);
				asp.refresh();
			}
		});
		buttonWireframeView.setBounds(10, 95, 106, 32);
		this.add(buttonWireframeView);

		JButton buttonPointView = new JButton("Points");
		buttonPointView.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				asp.getSim().setRepresentation(RepresentationEnum.POINT);
				asp.refresh();
			}
		});
		buttonPointView.setBounds(10, 138, 106, 32);
		add(buttonPointView);

		JButton buttonCoverView = new JButton("Cover");
		buttonCoverView.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				asp.getSim().setComponentView(ComponentViewEnum.OUTER);
				asp.refresh();
			}
		});
		buttonCoverView.setBounds(126, 52, 95, 32);
		add(buttonCoverView);

		JButton buttonInnerView = new JButton("Inner");
		buttonInnerView.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				asp.getSim().setComponentView(ComponentViewEnum.INNER);
				asp.refresh();
			}
		});
		buttonInnerView.setBounds(126, 95, 95, 32);
		add(buttonInnerView);

		JButton buttonOutline = new JButton("Outline");
		buttonOutline.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				asp.getSim().setOutline(true);  //boolean is not relevant here
				asp.refresh();
			}
		});
		buttonOutline.setBounds(126, 138, 95, 32);
		add(buttonOutline);
	}
}
